<template>
  <div class="o-top-bar">
    <img src="../../assets/top-bar/top_bar_bg.png" alt="" class="bg" />
    <div class="o-title">
      <div class="left">
        <div
          class="nav-item"
          :class="{ ['active-nav']: fullPath === '/' }"
          @click="handeJump('/')"
        >
          <img src="../../assets/top-bar/nav_bg.png" class="nav-bg-num" />
          <div class="nav-text">综合监测报警</div>
        </div>
        <div
          class="nav-item"
          :class="{ ['active-nav']: fullPath === '/zhjcBj' }"
          @click="handeJump('/zhjcBj')"
        >
          <img src="../../assets/top-bar/nav_bg.png" class="nav-bg-num" />
          <div class="nav-text">面雨量预报</div>
        </div>
        <div
          class="nav-item"
          :class="{ ['active-nav']: fullPath === '/fxyj' }"
          @click="handeJump('/fxyj')"
        >
          <img src="../../assets/top-bar/nav_bg.png" class="nav-bg-num" />

          <div class="nav-text">风险预警</div>
        </div>
      </div>
      <div class="center" @click="handeJump('/')">
        气象灾害风险预报预警子平台
      </div>
      <div class="right">
        <div
          class="nav-item"
          :class="{ ['active-nav']: fullPath === '/sampleProcess' }"
          @click="handeJump('/sampleProcess')"
        >
          <img src="../../assets/top-bar/nav_bg_right.png" class="nav-bg-num" />
          <div class="nav-text">检验评估</div>
        </div>
        <div
          class="nav-item"
          :class="{ ['active-nav']: fullPath === '/treeRing' }"
          @click="handeJump('/treeRing')"
        >
          <img src="../../assets/top-bar/nav_bg_right.png" class="nav-bg-num" />
          <div class="nav-text">致灾案例库</div>
        </div>
        <div
          class="nav-item"
          :class="{ ['active-nav']: fullPath === '/treeRing' }"
          @click="handeJump('/treeRing')"
        >
          <img src="../../assets/top-bar/nav_bg_right.png" class="nav-bg-num" />
          <div class="nav-text">危险性评估</div>
        </div>
      </div>
    </div>
  
  </div>
</template>
<script>
import Show from "@/views/home/show.vue";
import dayjs from "dayjs";
export default {
  name: "OTopBar",
  data() {
    return {
      ismessage: false,
      time: dayjs().format("HH:mm:ss"),
      date: dayjs().format("YYYY-MM-DD"),
      curTime: process.env.VUE_APP_UPDATE_TIME,
      fullPath: this.$route.fullPath,
    };
  },
  computed: {
    week() {
      const days = dayjs().day();
      const week = ["日", "一", "二", "三", "四", "五", "六"];
      return week[days];
    },
  },
  mounted() {
    console.log("----======", this.$routefullPath);
    setInterval(() => {
      this.time = dayjs().format("HH:mm:ss");
    }, 1000);
  },
  watch: {
    $route() {
      // let a = this.getBreadcrumb()
      // console.log('----======')
      this.fullPath = this.$route.fullPath;
    },
  },
  methods: {
    // 跳转
    handeJump(path) {
      console.log("-path");
      if (path === this.fullPath) {
        return;
      }
      this.$router.push({ path: path });
    },
    getBreadcrumb() {
      return this.$route.matched.filter((item) => item.name && item.meta.title);
    },
    // showMessage() {
    //   this.ismessage = !this.ismessage;
    // },
  },
};
</script>
<style lang="scss" scoped>
.o-top-bar {
  position: relative;
  width: 100%;
}
.bg {
  display: block;
  width: 100%;
  height: 120px;
}
.o-title {
  position: relative;
  z-index: 2;
}
.bar-wrap {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: space-between;
  // align-items: center;
  padding: 32px 20px 0;
  box-sizing: border-box;

  .left {
    display: flex;

    .home {
    }
    .stting {
      padding: 0 15px;
    }
  }
  .o-icon {
    font-size: 30px;
  }
  .countdown {
    // font-family: 'Impact Normal', 'Impact', sans-serif;
    // font-weight: 400;
    // font-style: normal;
    // font-size: 24px;
    // color: #ffffff;
    .dateTime {
      display: flex;
      flex-direction: column;
      align-items: flex-start;
      justify-content: center;
      font-size: 16px;
      font-family: PingFang SC;
      font-weight: bold;
      color: #ffffff;

      span {
        margin: 0;
      }

      .time {
        font-size: 24px;
        margin-left: 10px;
      }
    }
  }

  .right {
    display: flex;
    .o-icon {
      margin-left: 20px;
    }
  }
}

.o-title {
  position: absolute;
  // width: 100%;
  height: 100%;
  z-index: 1;
  left: 50%;
  top: 0;
  transform: translateX(-50%);
  display: flex;
  justify-content: center;
  .left,
  .right {
    display: flex;
    margin-top: 30px;
  }

  .nav-item {
    position: relative;
    font-family: "阿里巴巴普惠体 Medium", "阿里巴巴普惠体", sans-serif;
    font-weight: 500;
    font-style: normal;
    font-size: 18px;
    color: #ffffff;
    padding: 5px 0 0 0;

    text-align: center;
    .nav-text {
      width: 180px;
      height: 34px;
      padding-top: 10px;
      background-image: url("../../assets/top-bar/nav_bg_normal.png");
      background-size: 100% 100%;
      box-sizing: border-box;
    }

    .nav-bg-num {
      position: absolute;
      top: 0;
      width: 111px;
      height: 41px;
    }
  }

  .left {
    .active-nav .nav-text {
      background-image: url("../../assets/top-bar/act_nav_left.png");
    }
    .nav-bg-num {
      left: 10px;
    }
  }
  .right {
    .nav-text {
      background-image: url("../../assets/top-bar/normal_right.png");
      background-size: 100% 100%;
    }
    .nav-bg-num {
      right: 10px;
    }
    .active-nav .nav-text {
      background-image: url("../../assets/top-bar/act_nav_right.png");
    }
  }

  .center {
    word-break: keep-all;
    margin: 10px 150px;
    // width: 590px;
    color: #fff;
    text-shadow: 0px 0px 10px rgba(0, 200, 244, 1);
    font-size: 40px;
    font-weight: 700;
    text-align: center;
    font-family: "庞门正道标题体免费版 Bold", "庞门正道标题体免费版 常规",
      "庞门正道标题体免费版", sans-serif;
  }
}
.right-aligned-dialog {
  right: 0; /* 将对话框定位到右侧 */
  transform: translateX(0); /* 确保不会出现水平偏移 */
}
.el-dialog__wrapper right-aligned-dialog{
  position:fixed;
	top:60px;
	right:90px;
}
</style>
